"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

/**
 * 
 * @desc   判断字符串是否为json
 * @param  {String}  str
 * @return {Boolean} 
 */
function isJSON(str) {
  if (typeof str === "string") {
    try {
      var obj = JSON.parse(str);
      return obj && _typeof(obj) === "object";
    } catch (e) {
      console.log("error：" + str + "!!!" + e);
      return false;
    }
  }

  return false;
}

module.exports = isJSON;